﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Mingbo.Library;
using Mingbo.Library.Entity;
using System.Net;
using System.IO;
using System.Runtime.Serialization.Json;



namespace TestData
{
    public partial class Form1 : Form
    {
        static string APPKEY="631859723";
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            GetMsg();
        }

        private void GetMsg() { 
           string url =  string.Format("{0}?source={1}&count=10",GetURL.URL_PublicMsg,APPKEY);
           WebClient wc = new WebClient();
           wc.OpenReadCompleted += new OpenReadCompletedEventHandler(delegate(object s, OpenReadCompletedEventArgs e1) {
               StreamReader sr =new StreamReader(e1.Result);
               string result =sr.ReadToEnd();
               textBox1.Text=result;

               System.Text.Encoding ecoding = System.Text.Encoding.UTF8;
               byte[] bs = ecoding.GetBytes(result);
               MemoryStream ms = new MemoryStream(bs); 
               
               DataContractJsonSerializer dJson = new DataContractJsonSerializer(typeof(List<Msg>));
               List<Msg> o = (List <Msg>)dJson.ReadObject(ms);
               
               //Msg m1=(Msg)dJson.ReadObject(e1.Result);
           });
           wc.OpenReadAsync(new Uri(url), "get");

        

        }

    }
}
